<template>
<<<<<<< HEAD
    <div class="page-search">
        <!-- <mt-search autofocus v-model="value1" :result="filterResult">
          <mt-cell v-for="item in filterResult" :key="item" :title="item.type_name"></mt-cell>
        </mt-search>-->
        <!--{{repaireList}}-->
        <form action="/">
            <van-search
                    v-model="value"
                    show-action
                    placeholder="输入已维修/正在维修/未维修查找维修账单"
                    @search="onSearch"
                    @cancel="onCancel"
            />
        </form>
        <div>
            <div v-if="type == 'bj'">
                <van-empty image="search" description="描述文字"/>
            </div>
            <div v-if="type == 'search'">
                <div v-for="data in repaireData" class="repaire-list" :key="data.repaire_id">
                    <div class="repaire-list-head">
                        <div class="repaire-list-head1">
                            <span>订单编号:{{data.repaire_id}}</span>
                        </div>
                        <div>
                            <span>业主昵称:{{data.u_id}}</span>
                        </div>
                        <van-tag round :type="data.repaire_status == 0 ? 'danger' : (data.repaire_status == 1? 'success':'warning')">
                            {{data.repaire_status == 0 ? '未维修' : (data.repaire_status == 1 ?  '已维修':'正在维修')}}
                        </van-tag>
                    </div>
                    <div class="repaire-list-body">
                        <div class="repaire-list-body1">
                            <div>
                                <span>地点:{{data.addRess}}</span>
                            </div>
                            <span>是否审核:{{data.is_audit == 0 ? '未审核' :'已审核'}}</span>
                            <div>
                                <span>故障原因:{{data.type_name}}</span>
                            </div>
                            <div>
                                <span>故障描述:{{data.repaire_desc}}</span>
                            </div>
                            <div>
                                <span>维修评价:{{data.comment}}</span>
                            </div>
                        </div>
                        <div>
                            <!--<span>是否开启评价:</span><van-switch v-model="isComment" @change="openComment(data.repaire_id)" size="16px" />-->
                            <van-dialog v-model="show" title="标题" @confirm="sendMessage" show-cancel-button>
                                <div>
                                    <van-rate  v-model="comment" allow-half void-icon="star" void-color="#eee" />
                                </div>
                                <van-button type="primary" @click="submitComment" size="mini">提交</van-button>
                            </van-dialog>
                            <van-button v-if="data.repaire_status == 1" type="primary" @click="openDialog(data.repaire_id)" size="mini">评价</van-button>
                        </div>
                    </div>
                    <van-divider
                            :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }"
                    >
                    </van-divider>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import {Toast} from "mint-ui";

    export default {
        name: "",
        data() {
            //orgList:搜索后显示的列表，初始值应该从后台拿取
            return {
                activeNames: ['1'],
                type: "bj",
                checked:false,
                repaire_status: 0,
                u_id: "",
                comment:2.5,
                isComment:false,
                repaireList: [],
                value1: "",
                value: "",
                repaire_id:0,
                repaireData: [],
                show:false
            };
        },
        methods: {
            //开启评论
            /**
             * 搜索
             * @param val
             */
            onSearch(val) {
                let status = 0;
                if (val == null) {

                } else if (val == "已维修" || val == "未维修" || val == "正在维修") {
                    status = (val == "已维修" ? 1 : (val == "正在维修" ? 2 : 0));
                } else {
                    Toast("输入已维修/正在维修/未维修查找维修账单");
                }
                ;
                this.repaire_status = status;
                let data = JSON.parse(localStorage.getItem("login_data"));
                console.log("用户id：" + data.u_id);
                console.log("---" + this.repaire_status);
                this.u_id = data.u_id;
                axios.get("/safty/repaire/queryByUIdAndRepaireStatus", {
                    params: {
                        u_id: this.u_id,
                        repaire_status: this.repaire_status
                    }
                })
                    .then((res) => {
                        console.log(res);
                        if (res.success) {
                            console.log(res.data);
                            this.repaireData = res.data;
                        }
                    })
                    .catch((err) => {
                        console.log(err)
                    })
                this.type = "search";
            },
            onCancel() {
                Toast("取消");
                this.type = "bj";
            },
            queryData() {
                axios.get("safty/repaire/queryByUId", {
                        params: {u_id: JSON.parse(localStorage.getItem("login_data")).u_id}
                    })
                    .then(res => {
                        // console.log(res);
                        if (res.success) {
                            let result = res.data;
                            console.log(result);
                            // if(!(this.value1='')){
                            //     this.repaireList=this.repaireList.filter(value=>new RegExp(this.value1,'i').test(value.type_name));
                            // }else{
                            this.defaultResult = result;
                            // }
                            // console.log(this.repaireList)
                            console.log(2222222222);
                            // this.$router.push({path:'/home'})
                        } else {
                            Toast({
                                message: res.message,
                                duration: 1000
                            });
                        }
                    })
                    .catch(err => {
                        Toast({
                            message: err.message,
                            duration: 1000
                        });
                        console.log(err);
                    });
            },
            reset() {
                console.log("取消");
                // this.orgList=JSON.parse(JSON.stringify(this.normal))
            },
            onChange(id){
                console.log(id);
            },
            sendMessage(){

            },
            openDialog(id){
                this.show = true;
                this.repaire_id = id;
                console.log(id);
            },
            submitComment(id){
                let comment = this.comment + "星评价";
                // this.repaire_id = id;
                let value= this.value;
                console.log(id+"评论:" + this.comment);
                axios.put("safty/repaire/UpdateCommentById/"+comment+"/"+this.repaire_id)
                    .then(res=>{
                        if(res.success){
                            console.log(res);
                            this.show = false;
                            this.comment = 2.5;
                            // setTimeout(()=>{
                            //     this.$router.go(0);
                            // },500)
                            this.value = value;
                            this.onSearch(this.value);
                        }
                    })
                    .catch(err=>{

                    })
            }
        },
        watch: {},
        computed: {
            filterResult() {
                // this.queryData();//从后台差的数据,不能加括号
                // console.log("==============111111===============");
                // // console.log(this.repaireList);
                // console.log("==============111111==============");
                return this.defaultResult.filter(value =>
                    new RegExp(this.value, "i").test(value)
                );
            }
        },
        mounted() {
            this.queryData();
        }
    };
</script>

<style scoped>
    .page-search {
        margin-top: 10px;
    }

    .repaire-list{
        border: none;
        margin-bottom: 20px;
    }

    .repaire-list-head {
        display: flex;
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    .repaire-list-head1{
        display: block;
        width: 100%;
    }
    .repaire-list-body{
        /*border: 1px solid blue;*/
        display: flex;
        justify-content: left;
        flex-wrap: wrap;
        flex-direction: row;
        align-items: center;
    }
    .repaire-list-body .repaire-list-body1{
        width: 100%;
        display: block;
        justify-content: left;
    }
=======
  <div class="page-search">
    <!-- <mt-search autofocus v-model="value1" :result="filterResult">
      <mt-cell v-for="item in filterResult" :key="item" :title="item.type_name"></mt-cell>
    </mt-search>-->
    <!--{{repaireList}}-->
    <form action="/">
      <van-search
        v-model="value"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
      />
    </form>
    <div>
      <div v-if="type == 'bj'">
        <van-empty image="search" description="描述文字" />
      </div>
      <div v-if="type == 'search'">
        <van-grid direction="horizontal" :column-num="1">
          <van-grid-item icon="photo-o" text="文字" />
          <van-grid-item icon="photo-o" text="文字" />
          <van-grid-item icon="photo-o" text="文字" />
        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "mint-ui";

export default {
  name: "",
  data() {
    //orgList:搜索后显示的列表，初始值应该从后台拿取
    return {
      /**
       * 假数据
       */
      repaire: {
        name: "张三",
        status: 77,
        address: 11,
        money: 22
      },
      type: "bj",
      /**
       *
       */
      repaireList: [],
      value1: "",
      value: "",
      // 默认数据
      defaultResult: [
        "Apple",
        "Banana",
        "Orange",
        "Durian",
        "Lemon",
        "Peach",
        "Cherry",
        "Berry",
        "Core",
        "Fig",
        "Haw",
        "Melon",
        "Plum",
        "Pear",
        "Peanut",
        "Other"
      ]
    };
  },
  methods: {
    onSearch(val) {
      Toast(val);
      this.type = "search";
    },
    onCancel() {
      Toast("取消");
    },
    queryData() {
      axios
        .get("safty/repaire/queryByUId", {
          params: { u_id: JSON.parse(localStorage.getItem("login_data")).u_id }
        })
        .then(res => {
          // console.log(res);
          if (res.success) {
            let result = res.data;
            console.log(result);
            // if(!(this.value1='')){
            //     this.repaireList=this.repaireList.filter(value=>new RegExp(this.value1,'i').test(value.type_name));
            // }else{
            this.defaultResult = result;
            // }
            // console.log(this.repaireList)
            console.log(2222222222);
            // this.$router.push({path:'/home'})
          } else {
            Toast({
              message: res.message,
              duration: 1000
            });
          }
        })
        .catch(err => {
          Toast({
            message: err.message,
            duration: 1000
          });
          console.log(err);
        });
    },
    reset() {
      console.log("取消");
      // this.orgList=JSON.parse(JSON.stringify(this.normal))
    }
  },
  watch: {},
  computed: {
    filterResult() {
      // this.queryData();//从后台差的数据,不能加括号
      // console.log("==============111111===============");
      // // console.log(this.repaireList);
      // console.log("==============111111==============");
      return this.defaultResult.filter(value =>
        new RegExp(this.value, "i").test(value)
      );
    }
  },
  mounted() {
    this.queryData();
  }
};
</script>

<style scoped>
.page-search {
  margin-top: 10px;
}
>>>>>>> 70f7e19d6da4b30f0412d394b1171a015e63af36
</style>